home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-06 | 1.4 KB | 67 lines | [TEXT/MSET] |
- (*
- A rect+ is simply a rect that initializes its data to something other
- than zero. We also add some additional methods.
- *)
-
-
- :class rect+ super{ rect }
- \ DO NOT change the ivar mapping for rect+ because we use it extensively
- \ for mapping into toolbox records.
-
- :m classinit: \ let's always start with a non-null rectangle
- 50 50 100 100 put: super ;m
-
- :m move: { dx dy -- }
- self dx dy pack call OffsetRect ;m
-
- :m moveto: { l t -- }
- l t
- size: super ( l t width height)
- t + ( l t width b )
- swap ( l t b width )
- l + ( l t b r )
- swap
- put: self ;m
-
- :m erase:
- clear: super ;m
-
-
- \ rectangle coordinate access methods in 2-point form (x1,y1,x2,y2)
- :m getx1: ( -- x1) getx: topl ;m
- :m putx1: ( x1 -- ) putx: topl ;m
- :m gety1: ( -- y1) gety: topl ;m
- :m puty1: ( y1 -- ) puty: topl ;m
-
- :m getx2: ( -- x2) getx: botr ;m
- :m putx2: ( x2 -- ) putx: botr ;m
- :m gety2: ( -- y2) gety: botr ;m
- :m puty2: ( y2 -- ) puty: botr ;m
-
- :m getx1y1: ( -- x1 y1 ) get: topl ;m
- :m putx1y1: ( x1 y1 -- ) put: topl ;m
-
- :m getx2y2: ( -- x2 y2 ) get: botr ;m
- :m putx2y2: ( x2 y2 -- ) put: botr ;m
-
- :m width: ( -- w )
- getx2: self getx1: self - ;m
-
- :m height: ( -- h )
- gety2: self gety1: self - ;m
-
- :m setwidth: ( w -- ) \ will change x2 only
- getx1: self + putx2: self ;m
-
- :m setheight: ( h -- ) \ will change y2 only
- gety1: self + puty2: self ;m
-
- ;class
-
- endload
-
- *** EXAMPLE USE
-
- rect+ r
- draw: r
-